<?php
/**
 * class App_Form_User_ResetPwdConfirm
 * reset user password form
 *
 */
class App_Form_User_ResetPwdConfirm extends Zend_Form
{
    /**
     * init function - add elements
     *
     * @return object
     */
    public function init()
    {
        $this->setMethod('post');

        // new password
        $this->addElement('hidden', 'email', array(
            'required'      => true,
            'filters'       => array('StringTrim'),
            'validators'    => array('EmailAddress')
        ));

        // new password
        $this->addElement('hidden', 'key', array(
            'required'  => true,
            'filters'   => array('StringTrim')
        ));

        // new password
        $this->addElement('password', 'password_new', array(
            'required'   => true,
            'label'      => 'New Password: ',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 128))
            )
        ));

        // repeat password
        $this->addElement('password', 'password_confirm', array(
            'required'   => true,
            'label'      => 'Repeat Password: ',
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 128)),
                array('validator' => 'Identical', 'options' => array('token' => 'password_new')),
            )
        ));

        // verify code
        $this->addElement('captcha', 'captcha', array(
            'label' => 'Verify Code: ',
            'captcha' => array(
                'captcha' => 'Figlet',
                'wordLen' => 6,
                'timeout' => 300,
            ),
        ));

        $this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Reset my password',
        ));

        // And finally add some CSRF protection
        //$this->addElement('hash', 'csrf', array('ignore' => true));
    }

}